package com.roy.reversi.view;

import java.awt.Graphics;
import java.awt.event.MouseEvent;

import javax.swing.JPanel;

import com.roy.reversi.controller.Controller;
import com.roy.reversi.model.Chessboard;

public class GamePanel extends JPanel {

	private static final long serialVersionUID = 1L;

	private Controller controller;
	private ContainPanel contailPanel;
	
	public GamePanel(Controller controller) {
		this.controller = controller;
		this.setSize(controller.getGamePanelDimension());
		this.addMouseListener(new java.awt.event.MouseAdapter() {
			public void mouseClicked(MouseEvent e) {
				GamePanel.this.controller.put(Chessboard.BLACK, e.getX(), e.getY());
			}
		});
	}

	@Override
	protected void paintComponent(Graphics g) {
		controller.draw(g);
	}

	public ContainPanel getContailPanel() {
		return contailPanel;
	}

	public void setContailPanel(ContainPanel contailPanel) {
		this.contailPanel = contailPanel;
	}
	
	public void setInfo(String info){
		contailPanel.setInfo(info);
	}
	
}
